package com.scsj.supermarket.adapter;

import android.content.Context;
import android.view.View;
import android.widget.RatingBar;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.scsj.supermarket.R;
import com.scsj.supermarket.customview.MultiImageView;
import com.vondear.rxtools.RxDeviceTool;
import com.vondear.rxtools.RxImageTool;


import java.util.ArrayList;
import java.util.List;

/**
 *  商品评价
 */
public class GoodsCommAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private Context mContext;
    private int screenWidth;
    private MultiImageView multiImageView;

    public GoodsCommAdapter(Context mContext, List data) {
        super(R.layout.item_goods_comm, data);
        this.mContext = mContext;
        this.screenWidth = RxDeviceTool.getDisplayMetrics(mContext).widthPixels;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        if (helper.getAdapterPosition() % 2 == 0) {
            helper.getView(R.id.multiImageView).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.multiImageView).setVisibility(View.VISIBLE);
            multiImageView = helper.getView(R.id.multiImageView);
            multiImageView.setList(getGoodsEvaluateList(helper.getAdapterPosition()), screenWidth - RxImageTool.dip2px(70));
        }
        RatingBar rb_rating = helper.getView(R.id.rb_rating);
        rb_rating.setRating(helper.getAdapterPosition() % 5);
    }


    /**
     * 商品详情——评论图片
     */
    public static List<String> getGoodsEvaluateList(int i) {
        List<String> mList = new ArrayList<>();
        if (i > 0)
            mList.add("http://imgsrc.baidu.com/imgad/pic/item/4bed2e738bd4b31c027523868cd6277f9e2ff846.jpg");
        if (i > 1)
            mList.add("http://www.lagou.com/image1/M00/01/24/CgYXBlTUYpeAaE1IAAHXd642ctI466.jpg");
        if (i > 2)
            mList.add("http://img0.imgtn.bdimg.com/it/u=4104948062,744646040&fm=11&gp=0.jpg");
        if (i > 3)
            mList.add("http://pic63.nipic.com/file/20150319/7487939_201655610000_2.jpg");
        if (i > 4)
            mList.add("http://getimg.jrj.com.cn/images/2014/01/prnewsimg/one_20140124141205613.jpg");
        if (i > 5)
            mList.add("http://pic35.nipic.com/20131107/7487939_020046479000_2.jpg");
        return mList;
    }
}
